package common

import (
	"go-web-admin/utils"
	"time"
)

// BaseEntity 公共字段
type BaseEntity struct {
	Id         string    `json:"id"`
	CreateTime time.Time `json:"create_time"default:time.Now(),`
	UpdateTime time.Time `json:"update_time"default:time.Now(),`
	IsDelete   int8      `json:"is_delete"default:0`
}

// InitBaseEntity 初始化公共字段
func InitBaseEntity(base *BaseEntity) {
	now := time.Now()
	base.Id = utils.GenIdStr()
	base.CreateTime = now
	base.UpdateTime = now
	base.IsDelete = 0
}
